import java.net.SocketTimeoutException;
import java.util.ArrayList;
import java.util.Collections;
import java.util.HashMap;
import java.util.TreeSet;

public class pokerGame {



    //牌盒
    static ArrayList<Integer> list = new ArrayList<>();
    static HashMap<Integer,String>hm=new HashMap<>();
    //准备牌
    //静态代码块：随着类的加载而加载，而且只执行一次
    static {
        String[] color = {"♦", "♣", "♥", "♠"};
        String[] number = {"3", "4", "5", "6", "7", "8", "9", "10", "J", "Q", "K", "A", "2"};
        //序号
        int serialNumber=1;
        for(String n:number){
            for(String c:color){
                hm.put(serialNumber,c+n);
                list.add(serialNumber);
                serialNumber++;
            }
        }
        hm.put(serialNumber,"小王");
        list.add(serialNumber);
        serialNumber++;
        hm.put(serialNumber,"大王");
        list.add(serialNumber);

    }

    public pokerGame() {
        //洗牌
        Collections.shuffle(list);
        //发牌
        TreeSet<Integer> lord=new TreeSet<>();//底牌
        TreeSet<Integer>play1=new TreeSet<>();
        TreeSet<Integer>play2=new TreeSet<>();
        TreeSet<Integer>play3=new TreeSet<>();

        for (int i = 0; i < list.size(); i++) {
            int poker = list.get(i);//牌的序号
            if(i<=2){
                lord.add(poker);
            }
            if(i%3==0){
                play1.add(poker);
            }
            else if(i%3==1){
                play2.add(poker);
            }
            else {
                play3.add(poker);
            }
        }
        //看牌
        lookPoker("底牌",lord);
        lookPoker("明",play1);
        lookPoker("松",play2);
        lookPoker("龙",play3);

    }
    //玩家的名字，拍的序号
public void lookPoker(String name,TreeSet<Integer> ts){
    System.out.println(name);
    for (Integer Number : ts) {
        String poker = hm.get(Number);
        System.out.print(poker);
    }
    System.out.println();
}

}
